local table_name = "sw"
local old_table = IMPORT_D:get_table(table_name)
if not old_table then
    return
end

local attrib = IMPORT_D:get_table("swattribute")
if not attrib then
    return
end

local new_table = {}
for _, tbl in pairs(attrib) do repeat
    local config = old_table[tbl.swid]
    if not config then
        break
    end

    local swid, level = tbl.swid, tbl.level

    tbl.swid = swid
    if not new_table[swid] then
        new_table[swid] = setmetatable({ [level] = setmetatable(tbl, { __index = config }) }, { __index = config })
    else
        new_table[swid][level] = setmetatable(tbl, { __index = config })
    end
until true end

IMPORT_D:set(table_name, new_table)
